package sort;

/**
 * Created by Ghost on 2015/4/16.
 */
public class testQS {

    public void quicksort(int[] num, int start, int end){

        if(start>=end)
            return;

        int flag = num[start];
        int i=start,j=end;
        while(i<j){
            for(;j>i && num[j]>=flag;j--);
            if(j>i){
                num[i] = num[j];
                i++;
            }
            for(;i<j && num[i]<=flag;i++);
            if(i<j){
                num[j]= num[i];
                j--;
            }
        }
        num[i] = flag;
        quicksort(num, start, i-1);
        quicksort(num,i+1, end);
    }

    public static void main(String[] args){
        testQS testQS = new testQS();
        int[] num = {3};
        testQS.quicksort(num,0,num.length-1);
        for(Integer i:num)
            System.out.println(i);
    }
}
